package com.woniu.microprojectserver.personmag.service.impl;

import com.woniu.microcommonsserver.entity.BuildPersonInfoEntity;
import com.woniu.microcommonsserver.entity.LpersonInfoEntity;
import com.woniu.microcommonsserver.entity.SpacePersonInfoEntity;
import com.woniu.microprojectserver.personmag.mapper.PersonMapper;
import com.woniu.microprojectserver.personmag.service.IPersonService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ：pengchufeng
 * @date ：Created in 2021/2/1
 * @description：负责人service实现
 */
@Transactional(readOnly = true)
@Service
public class PersonServiceImpl implements IPersonService {

    @Resource
    private PersonMapper personMapper;

    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    public List<LpersonInfoEntity> findByBuildId(String id) {
        return personMapper.findByBuildId(id);
    }

    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    public List<LpersonInfoEntity> findBySpaceId(String id) {
        return personMapper.findBySpaceId(id);
    }

    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    public void addByBuild(LpersonInfoEntity lpersonInfoEntity) {
        personMapper.addByBuild(lpersonInfoEntity);
    }

    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    public boolean addByBuildWith(BuildPersonInfoEntity buildPersonInfoEntity) {
        personMapper.addByBuildWith(buildPersonInfoEntity);
        return true;
    }

    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    public boolean update(LpersonInfoEntity lpersonInfoEntity) {
        personMapper.update(lpersonInfoEntity);
        return true;
    }

    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    public boolean deleteByPersonBuild(String id) {
        personMapper.deleteByPersonBuild(id);
        return true;
    }

    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    public boolean deleteByBuild(String id) {
        personMapper.deleteByBuild(id);
        return true;
    }

    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    public void addBySpace(LpersonInfoEntity lpersonInfoEntity) {
        personMapper.addBySpace(lpersonInfoEntity);
    }

    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    public boolean addBySpaceWith(SpacePersonInfoEntity spacePersonInfoEntity) {
        personMapper.addBySpaceWith(spacePersonInfoEntity);
        return true;
    }

    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    public boolean deleteByPersonSpace(String id) {
        personMapper.deleteByPersonSpace(id);
        return true;
    }

    @Override
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    public boolean deleteBySpace(String id) {
        personMapper.deleteBySpace(id);
        return true;
    }
}
